/*
 * Copyright (C) <2009>  <Matthew Dickinson>
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.pulsarwebdevelopment.concordance.plugins;

import java.applet.*;
import java.io.StringWriter;

import com.pulsarwebdevelopment.concordance.Concordance;
import com.pulsarwebdevelopment.concordance.ConcordanceOutput;
import com.pulsarwebdevelopment.concordance.ConcordanceOutputStream;
import com.pulsarwebdevelopment.concordance.Tools;
import com.pulsarwebdevelopment.concordance.Verse;

/**
 * Provides the functionality of LiveSearch in applet form
 * @author Matthew Dickinson
 * Last updated: 8/10/2009
 */
public class LiveSearchApplet extends Applet{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Concordance conc;
	
	
	public LiveSearchApplet(){
		super();
		//ConcordanceTool concTool = new ConcordanceTool();
		
		//concTool.openConcordance();//new File("/home/quentin/Desktop/quizzing/GEPCP_large.conc"));
		
		//conc = concTool.getConcordance();
	}
	
	public String findMatch(String patt){
		//Concordance thing = conc.getMatchingWordSet(capitalize(patt) + ".*");
		StringWriter outStrWriter = new StringWriter();
		ConcordanceOutput<String, Verse> output = 
			new ConcordanceOutputStream<String, Verse>(outStrWriter, ConcordanceOutputStream.ListStyle.SINGLE_LINE_TRUNCATED);
		conc.getMatchingWordSet(Tools.capitalize(patt) + ".*", output);//thing.toHTMLString();
		return outStrWriter.toString();
	}
	
}
